#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
int n, m;
int a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  ll tot = 0;
  rep(i, 1, n) tot += 1ll * (n + 1) * a[i];
  rep(j, 1, 24) {
    ll sum = 0;
    int mask = (1 << j) - 1;
    map<int, int> mp;
    rep(i, 1, n) mp[a[i] & mask]++;
    rep(i, 1, n) {
      int x = a[i] & mask;
      int y = (mask + 1 - x) & mask;
      int cnt = mp[y];
      if (x == y) cnt++;
      sum += 1ll * cnt * a[i];
    }
    tot -= sum >> j;
  }
  cout << tot;
  return 0;
}